//
//  Welcome.swift
//  weibo
//
//  Created by 陈经纬 on 16/7/23.
//  Copyright © 2016年 陈经纬. All rights reserved.
//

import UIKit
import SDWebImage
class Welcome: UIViewController {

    @IBOutlet weak var imageView: UIImageView!

    @IBOutlet weak var bottomLenth: NSLayoutConstraint!
    @IBOutlet weak var textLable: UILabel!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
  
        textLable.alpha = 0;
        
        //设置头像为圆角
        imageView.layer.cornerRadius = 50
        imageView.layer.masksToBounds = true
        
        assert(UserAccount.loadUserAccount() != nil,"显示欢迎界面需要先授权登录")
        
        guard let url = NSURL(string: (UserAccount.loadUserAccount()!.avatar_large)!) else{
        imageView.image = UIImage(named: "avatar_default_big")
            return
        }
        imageView.sd_setImageWithURL(url)
    }
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
        
        self.bottomLenth.constant = UIScreen.mainScreen().bounds.height - self.bottomLenth.constant
        
        
           
            UIView.animateWithDuration(2, animations: {
                self.view.layoutIfNeeded()
                }, completion: { (true) in
                    UIView.animateWithDuration(2, animations: { 
                        self.textLable.alpha = 1
                    })
                    
                    //动画执行完毕立即跳转跳转到main界面
                    //通知的方法,"main"标记通知的信息,在AppDelegate实现通知方法
                    NSNotificationCenter.defaultCenter().postNotificationName(SwithrootViewController, object: "main")
            })
        
    }

}


